<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	request.setAttribute("path", request.getContextPath());
%>
<script type="text/javascript">
$(function(){
	validate();
});
function validate(){

	$("#name").change(function (){
		check.emptyCheck("name");
	});

	$("#contact").change(function (){
		validatContact();
	});

	$("#secondOrg").change(function(){
		if(${isNew}){
			check.emptyCheck("secondOrg");
		}
	});
	
}

function  validatContact(){

	var val = $("#contact").val();
	if(!common.isEmpty(val)){
		return check.mobile("contact") || check.phone("contact");
	}	
	check.hideMsg("contact");
	return true;
}
function validateOrg(){

	if(${isNew}){
		return check.emptyCheck("secondOrg");
	}
	return true;
}
function save(){
	
	var uri = "${root}/shop/update"
	if(check.emptyCheck("name") & validatContact() & validateOrg()){
		common.ajaxSubmit(uri,"shopForm","保存网点失败","",'common.windowClose()');
	}
	
}
</script>
<c:if test="${!isNew}">
<jsp:include page="shop_tabs.jsp"></jsp:include>
</c:if>
<jsp:include page="../../base/master_js.jsp"></jsp:include>
<form class="form-horizontal" id="shopForm" role="form">
	<jsp:include page="../../base/token.jsp" />
	<input type="hidden" name="id" id="id" value="${shop.id}" />
	<table class="table table-hover">
		<c:if test="${!isNew}">
		<tr>
			<th>大区(旧):</th>
			<td>
				 <span class="input-xlarge uneditable-input"><c:out value="${shop.firstOrg.name}"></c:out></span></p>
			</td>
			<th>办事处(旧):</th>
			<td>
				 <span class="input-xlarge uneditable-input"><c:out value="${shop.secondOrg.name}"></c:out></span></p>
			</td>
		</tr>
		</c:if>
		<tr>
			<th>大区:</th>
			<td>
				 <select id="firstOrg" name="firstOrg" class="input-xlarge" onchange="firstOrgChange(this,'secondOrg',true)">
					<option value=""></option>
					<c:forEach var="item" items="${firstOrgs}">
						<option value="${item.id }"><c:out value="${item.name }"/></option>
					</c:forEach>
				</select>
			</td>
			<th>办事处:</th>
			<td>
					<select id="secondOrg" name="secondOrg" class="input-xlarge" >
				</select>
			</td>
		</tr>
		
		<tr>
			<th>类型:</th>
			<td>
		    	<c:forEach var="item" items="${shopTypes}">
		    		&nbsp;&nbsp;&nbsp;
		       		<label class="radio inline">
					    <input <c:if test="${shopType == item}">checked</c:if> type="radio" name="ShopType"  value="${item}"   ><spring:message code="${item}"/>
					 </label>
					 
			   </c:forEach>
			</td>
			<th>名称:</th>
			<td>
				<input type="text" class="input-xlarge" name="name" id="name" maxlength="200" value="${shop.name }" >
			</td>
		</tr>
			<tr>
			<th>负责人:</th>
			<td>
		    	<input type="text" class="input-xlarge" name="shopPic" id="shopPic" maxlength="100" value="${shop.shopPic}"  >
			</td>
			<th>电话:</th>
			<td>
				  <input type="text" class="input-xlarge" name="contact" id="contact" maxlength="100" value="${shop.contact }" >
			</td>
		</tr>
		<tr>
			<th>地址:</th>
			<td colspan="3">
				<input type="text" class="input-xxlarge" name="address" id="address" maxlength="300" value="${shop.address}"   >
			</td>
		</tr>
		<tr>
			<th>描述:</th>
			<td colspan="3">
				<input type="text" class="input-xxlarge" maxlength="500" name="comments" value="${shop.comments}" id="comments"  >
			</td>
		</tr>
		<tr>
			<th>创建人:</th>
			<td><span class="input-xlarge uneditable-input"><c:out value="${product.createUser}"></c:out></span></td>
			<th>创建时间:</th>
			<td><span class="input-xlarge uneditable-input"><fmt:formatDate value="${product.createTime}" pattern="yyyy-MM-dd hh:mm"/></span></td>
		</tr>
		<tr>
			<th>更新人:</th>
			<td><span class="input-xlarge uneditable-input"><c:out value="${product.updateUser}"></c:out></span></td>
			<th>更新时间:</th>
			<td><span class="input-xlarge uneditable-input"><fmt:formatDate value="${product.updateTime }" pattern="yyyy-MM-dd hh:mm"/></span></td>
		</tr>
	</table>

	<div class="form-actions text-center">
	      <button type="button" class="btn btn-success" onclick="save()">保存</button>
	       <button type="button" class="btn btn-default" onclick="common.windowClose()">关闭</button>
	</div>
</form>
